home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / ja90 / DMode.txt next >
Encoding:
Text File  |  1991-01-22  |  5.5 KB  |  149 lines

  1.  
  2. ECS Display Modes and ILBM CAMG
  3.  
  4. by Carolyn Scheppner
  5.  
  6. Under previous versions of the Amiga operating system and hardware,
  7. the available display modes such as HIRES, LACE, HAM, HALFBRITE,
  8. DUALPF, and assorted combinations of these display modes could all be
  9. described in a 16-bit ViewPort mode field (often referred to as a
  10. viewmode).
  11.  
  12. The 1.3 procedure for storing an Amiga viewmode in an ILBM was to take
  13. the 16-bit viewmode, mask out the undesirable bits GENLOCK_AUDIO,
  14. GENLOCK_VIDEO, VP_HIDE, and SPRITES, and store the result as a long
  15. (32-bit) value in a CAMG chunk (the upper 16 bits of the long would be
  16. 0).
  17.  
  18. The 1.3 procedure for reading ILBM CAMG chunk was to read the 32-bit
  19. value, mask out the undesirable bits mentioned above, and then use the
  20. low word of the result as a 16-bit value for ViewPort.Modes or
  21. NewScreen.Modes when opening a display.
  22.  
  23. The 2.0 operating system and the ECS chips support an extensible
  24. number of display modes - too many to be specified by the previous
  25. method where individual bits mapped to a limited number of specific
  26. display characteristics.  Under 2.0, display modes are now specified
  27. by a 32-bit ModeID which is not stored in the ViewPort, but is instead
  28. held in private graphics lists of extended display information linked
  29. into an extension of the ColorMap structure.  System functions are
  30. provided for accessing this extended display information.  A simple
  31. 2.0 function is provided for getting the new 32-bit ModeID for any
  32. ViewPort:
  33.  
  34.       ULONG modeID = GetVPModeID(struct ViewPort *vp);
  35.  
  36.  
  37. The 2.0 scheme for CAMG is to save the entire 32-bit ModeID,
  38. untouched, in the CAMG chunk.
  39.  
  40. Although ModeIDs are numeric values rather than bit masks, the current
  41. 2.0 ModeIDs have been specially designed to contain compatible
  42. old-style bits in their low word for the matching (or closest match)
  43. of an old ViewPort mode.
  44.  
  45. For example, the 2.0 ModeID for a Hires-Interlace display has the
  46. HIRES and LACE bits set in its low word.  And the 2.0 ModeID for
  47. Productivity-Interlace also has the HIRES and LACE bits set in its low
  48. word.  This is because on a non-ECS or non-2.0 system, Hires-Interlace
  49. is the closest old viewmode available for attempting to display a
  50. Productivity-Interlace image.
  51.  
  52. By storing the entire 32-bit ModeID in the CAMG chunk under 2.0, new
  53. reader applications can attempt to redisplay the image in its intended
  54. display mode when possible (i.e., when running under 2.0 on a system
  55. capable of the display mode).  Old readers will not be able to use the
  56. new display modes, but their existing code will truncate the new
  57. 32-bit ModeID into a 16-bit viewmode which will generally provide an
  58. old mode capable of displaying the image in some fashion.
  59.  
  60. New ILBM readers and readers revised for 2.0 can apply logic such as
  61. the following when supporting new display modes: 
  62.  
  63.  
  64.  
  65. struct Screen *openidscreen(ULONG modeid,SHORT wide, SHORT high, SHORT deep)
  66. {
  67. extern struct Libary *GfxBase;
  68. struct Screen *screen;
  69.  
  70. if(GfxBase->lib_Version >= 36)
  71.     {
  72.     /* if mode is not available, try a fallback mode */
  73.     if(ModeNotAvailable(modeid))    modeid = fallbackmode(modeid).
  74.  
  75.     if(!(ModeNotAvailable(modeid))) /* if mode is available */
  76.         {
  77.         /* We have an available mode id
  78.         Here you may wish to create a custom, or centered, or overscan
  79.         display clip based on the size of the image.  Or just use
  80.         one of the standard clips.
  81.  
  82.         The 2.0 Display program uses QueryOverscan to get the settings
  83.         of this modeid's OSCAN_TEXT, OSCAN_STANDARD, and OSCAN_MAX.
  84.         Display centers the screen (via TopEdge and LeftEdge) within
  85.         the user's OSCAN_STANDARD settings, and creates a display clip
  86.         by using the same values and then clipping the values to be
  87.         within OSCAN_MAX limits.  If the centered screen ends up lower
  88.         than user's OSCAN_TEXT settings, I move it up to same MinY as his
  89.         OSCAN_TEXT --- otherwise his Workbench might peek over the top.
  90.         */
  91.  
  92.         /*
  93.         Now use extended OpenScreen or OpenScreenTags for this modeid.
  94.         (this gives you the benefit of system-supported overscan, etc.)
  95.         */
  96.         }
  97.     }
  98.  
  99.  
  100. if no display opened yet  (either not 2.0 or mode not available or can't open)
  101.     {
  102.     Try an old-style OpenScreen with NewScreen.Modes = mode & VPMODEMASK;
  103.     }
  104.  
  105. return(screen);
  106. }
  107.  
  108.  
  109.  
  110. /*
  111.  * fallbackmodeid - passed an unavailable modeid, attempts to provide an
  112.  *                  available replacement modeid to use instead
  113.  */
  114.  
  115. #define VPMODEMASK (~(GENLOCK_AUDIO|GENLOCK_VIDEO|VP_HIDE|SPRITES))
  116.  
  117. ULONG fallbackmodeid(ULONG modeid, SHORT wide, SHORT high, SHORT deep)
  118. {
  119. extern struct Library *GfxBase;
  120. ULONG newmodeid;
  121.  
  122.     /* if it's an old 1.3-style mode, mask out inappropriate bits
  123.      */
  124.     if(!(modeid & MONITOR_ID_MASK)) newmodeid = modeid & VPMODEMASK;
  125.  
  126.     else newmodeid = modeid;  /* else start with what was passed */
  127.  
  128.     if(GfxBase->lib_Version >= 36)
  129.         {
  130.             if(ModeNotAvailable(newmodeid))
  131.             {
  132.             /* Here you should either be asking the user what mode they want
  133.             * OR searching the display database and choosing an appropriate
  134.             * replacement mode based on what you or the user deem important
  135.             * (colors, or aspect, or size, etc.).  You could also use a built
  136.             * in table for modes you know about, and substitute mode you wish
  137.             * to use when the desired mode is not available.
  138.             */
  139.  
  140.             newmodeid = ??? 
  141.             } 
  142.         }
  143.  
  144. #ifdef DEBUG
  145.         printf ("Trying 0x%08lx instead of 0x%08lx\n",newmodeid,modeid);
  146. #endif
  147.     return(newmodeid);
  148. }
  149.